<template>
	<view class="ys">
		<y-header></y-header>
		<view class="userbody">
			<view class="usertop">
				<y-bread :name="pageName"></y-bread>
			</view>
			<view class="usermain">
				<view class="left">
					<y-usermenu></y-usermenu>
				</view>
				<view class="right">
					<view class="saletop">
						<text>{{$t('index.wdsc')}}</text>
					</view>
					<view class="salelist">
						<y-goodslist :list="list" styleType="row" collectField="goods_id"
							@collectGoods="collectGoods"></y-goodslist>
					</view>
					<view class="no_list" v-if="list.length == 0">
						- {{$t('index.zwsc')}} -
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		collectList
	} from "@/api/user.js"
	export default {
		data() {
			return {
				pageName: this.$t('index.wdsc'),
				list: [],

			}
		},
		onLoad() {
			this.collectList()
		},
		methods: {
			collectList() {
				collectList().then(res => {
					if (res.code == 0) {
						this.list = res.data
					}
				})
			},
			collectGoods(item, status) {
				uni.$showMsg(status ? this.$t('index.sccg') : this.$t('index.qxsc'))
				let index = this.list.findIndex(goods => goods.id == item.id)
				if (index >= 0) {
					this.list.splice(index, 1)
				}
			},
		}
	}
</script>

<style lang="scss">
	.userbody {
		max-width: 1180px;
		margin: 0 auto;
		padding: 10px;
		box-sizing: border-box;
	}

	.usermain {
		display: flex;
		justify-content: space-between;

		.left {
			box-sizing: border-box;
			width: 25%;
			max-width: 265px;
			margin-top: 20px;
			margin-bottom: 20px;
		}

		.right {
			box-sizing: border-box;
			width: 75%;
			padding-right: 1%;
			margin-bottom: 20px;

			.saletop {
				background-color: white;
				box-shadow: #99999933 0px 1px 4px;
				margin-bottom: 10px;

				text {
					position: relative;
					display: block;
					padding: 15px 12px;
					font-size: 14px;
					line-height: 20px;
					color: #ff5353;
					font-weight: 500;
					pointer-events: none;
					box-sizing: border-box;

					&::after {
						position: absolute;
						bottom: 8px;
						height: 3px;
						width: 60px;
						background: #ff5353;
						left: 12px;
						content: '';
					}
				}
			}
		}
	}

	@media (max-width:768px) {
		.usermain {
			.left {
				display: none;
			}

			.right {
				width: 100%;
				padding: 0;
			}
		}

		.usertop {
			display: none;
		}

		.pc {
			display: none;
		}
	}
</style>